-- 计算距离
-- 根据经纬度计算距离
-- A(lngA,latA) B(lngB,latB)
-- C = sin(MLatA)*sin(MLatB)*cos(MLonA-MLonB) + cos(MLatA)*cos(MLatB)
-- Distance = R*Arccos(C)*Pi/180

local R_EARTH = 6371000
local CONSTA = R_EARTH * math.pi / 180;

local sin = math.sin
local cos = math.cos
local acos = math.acos

function distance(p1,p2)
	print(math.sin(math.pi/2))

	local c = sin(p1.lat) * sin(p2.lat) * cos(p1.lng - p2.lng) + cos(p1.lat) * cos(p2.lat)
	local d = CONSTA * acos(c)
	return d
end

local pA = {
	lng=116.405285,
	lat=39.904989
}

local pB = {
	lng=116.458605,
	lat=39.90511
}

local d = distance(pA,pB)
print(d)
